const API = require('../../pages/api/index')
const {
  typeJson
} = require('../../utils/typejson')
let prolist = wx.getStorageSync('prolist') == '' ? wx.getStorageSync('prolist') : JSON.parse(wx.getStorageSync('prolist'))


Page({

  /**
   * 页面的初始数据
   */
  data: {
    pulldown: "",
    bgc:"background:skyblue;",  
    bga:"",
    pullup: 2,
    show:false,  
    addButton: true,
    Refresh: false,
    prolist: wx.getStorageSync('prolist') == '' ? wx.getStorageSync('prolist') : JSON.parse(wx.getStorageSync('prolist')),
    listConfig: [{
        label: '审核状态',
        prop: 'approStatus',
        jsonType: typeJson.approStatus,

      },
      {
        label: '作业内容',
        prop: 'operateDept',

      }
    ],

    slide: {
      slideButton: {
        text: '编辑',
        extClass: 'test',
        src: '/page/weui/cell/icon_star.svg', // icon的路径
      },
      formConfig: [
         
      ],
    },

    formConfig: [

      {
        label: '申请动火单位',
        prop: 'addDept',
        required: true,
      },
      {
        label: "作业单位",
        prop: "operateDept",
        required: true,
      },
      {
        label: "动火作业点",
        prop: "point",
        required: true,
      },
      {
        label: '作业内容',
        prop: 'content',
        required: true,
      },  
      {
        label: '动火人①',
        prop: 'oneId',
        code:"oneNo", 
        type: 'multiDropDown',
        required: true,
        hidden: 'look',
        net: {
          url: '/app/specialWorkerInfo/getList',
          method: 'post',
          data: {
            mineId: true,

          },
          key: 'empId',
          value: 'name'
        }
      },

      {
        label: "证件号①",
        prop: "oneNo",
        type:'inputType'
      },
      {
        label: '特种作业类别①',
        prop: 'oneSpecial',
      },
      {
        label: '动火人②',
        prop: 'secondId',
        type: 'multiDropDown',
        code:"secondNo",
        hidden: 'look',
        net: {
          url: '/app/specialWorkerInfo/getList',
          method: 'post',
          data: {
            mineId: true,

          },
          key: 'empId',
          value: 'name'
        }
      },

      {
        label: "证件号②",
        prop: "secondNo",
        type:'inputType'
      },
      {
        label: '特种作业类别②', 
        prop: 'secondSpecial',    
      },
      {
        label: '动火监护人',
        prop: 'guardianId',
        type: 'multiDropDown',
        required: true,
        hidden: 'look',
        net: {
          url: '/app/specialWorkerInfo/getList',
          method: 'post',
          data: {
            mineId: true,

          },
          key: 'empId',
          value: 'name'
        }
      },
      
      {
        label: '动火等级',
        prop: 'level',
        required: true,
      },
      {
        label: '动火开始时间',
        prop: 'startTime',
        type: "dateTime",
        required: true,
      },
      {
        label: '动火结束时间',
        prop: 'endTime',
        type: "dateTime",
        required: true,
      },

      {
        label: '可燃气体含量',
        prop: 'gas',
        required: true,
      },
      {
        label: "有毒气体含量",
        prop: "toxicGas",
        required: true,
      },
      {
        label: "动火设备内部构件清理干净，蒸汽吹扫或水洗合格，达到动火条件。",   
        prop: "a",
        type: 'boxbl',
       checked: true,  
       required: true,
      },
      {
        label: "在井口、井筒和主要进风巷内动火作业时，必须撤出井下和回风侧所有作业人员。",
        prop: "b",
        type: 'boxbl',
       checked: true,
       required: true,
      },
      {
        label: "动火点周围（最小半径15米）的下水井、地漏、地沟、电缆沟等已清除易燃物，并已采取覆盖、铺砂、水封等手段进行隔离。",
        prop: "c",
        type: 'boxbl',
       checked: true,
       required: true,
      },
      {
        label: "距动火点30米内严禁排放各类可燃气体，15米内严禁堆放各类可燃液体。动火点10米范围内及动火点下部区域严禁同时进行可燃溶剂清洗和喷漆等作业。",
        prop: "d",
        type: 'boxbl',
       checked: true,
       required: true,
      },
      {
        label: "高处作业应采取防火花飞溅措施。",
        prop: "e",
        type: 'boxbl',
       checked: true,
       required: true,
      },
      {
        label: "电焊回路线应该接在焊件上，把线不得穿过下水井或与其他设备搭线。",
        prop: "f",
        type: 'boxbl',
       checked: true,
       required: true,
      },
      {
        label: "乙炔瓶应直立放置，氧气瓶与乙炔气瓶间距不应小于5米，二者与动火点明火或其他能源间距不应小于10米",
        prop: "g",
        type: 'boxbl',
       checked: true,
       required: true,
      }, 
      {
          label: "现场配备",
          prop: "h",
          text1:"灭火器(个)", 
          text2:"铁锹(把)",
          type:"numberNew",
          required: true,
        },
       
        {
          label: "现场是否配备灭火器/铁锹",
          prop: "i",
          type: 'boxbl', 
         checked: true,
         required: true,
        },
     
      {
        label: "在受限空间内进行动火作业，临时用电作业时，不得同时进行刷漆、喷漆作业或使用可燃溶剂清洗等其他可能散发易燃气体、易燃液体作",
        prop: "j",
        type: 'boxbl', 
       checked: true,
       required: true,
      },

      {
        label: "危害识别及其他补充措施。",
        prop: "k",
        type: 'boxbl',
       checked: true,
       required: true,
      }
   

    ],


    net: {

      select: {
      
      },
      delete: {
        url: '/app/siteWorkapprove/delete',
        method: 'post',
        data: {

        }
      },
      insert: {
        url: '/app/fireFlow/insert',
        method: 'post',
        data: {
          mineId: true,
          addMemberId: "userid",  
        },
        type:'下一步',
        code:1,
        inputType:'inputType'

      },
      update: {
        url: '/app/fireFlow/update',
        method: 'post',
        data: {
          approStatus:3
        }
      }


    },
    showCom: true
  },
  showClose(e){
    this.setData({
      show: e.detail.show
    })
  },
  showChange(e) {
    this.setData({
      show: e.detail.show
    })
  },
 
onLoad(){
  this.getlist(1)
},

styleColor(e){
 
  let {type} = e.currentTarget.dataset;
  if(type=='2'){
  
    this.getlist(type)
    this.setData({
      bgc:"background:skyblue;",  
      bga:""
    })
    this.onShow()
  }else{
    this.getlist(type)
    this.setData({
      bga:"background:skyblue;",
      bgc:""
    })
    this.onShow()
  }
  },

getlist(T){
  let {userid} = this.data.prolist;
 
  this.setData({
    net:{
      select: {
        url: `/app/flowDetail/getList`,
        method: 'post',
        data: {
          mineId: true,
          auditMemberId:"userid",
          type:T
        }
      },
      delete: {
        url: '/app/siteWorkapprove/delete',
        method: 'post',
        data: {

        }
      },
      insert: {
        url: '/app/fireFlow/insert',
        method: 'post',
        data: {
          mineId: true,
          addMemberId: "userid",  
        },
        type:'下一步',
        code:1,
        inputType:'inputType'
      },
      update: {
        url: '/app/fireFlow/update',
        method: 'post',
        data: {
          approStatus:3
        }
      }
    }
  })

},


  /**
   * 生命周期函数--监听页面加载
   */


  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
   
    this.setData({
      showCom: false
    });
    this.setData({
      showCom: true
    });
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    wx.showLoading({
      title: '刷新中...',
    })
    this.setData({
      Refresh: true
    })
    wx.hideLoading();
    wx.stopPullDownRefresh()
    this.setData({
      Refresh: false
    })
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    this.setData({
      pullup: this.data.pullup + 1
    })
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})